﻿using MediatR;
using T_vehicle.API.Application.Command.IllegalCommand;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.IllegalCommandHandlers
{
    public class DelIllgalCommandHandlers:IRequestHandler<DelIllgalCommand,int>
    {
        private readonly IIllegalRepository illegalRepository;

        public DelIllgalCommandHandlers(IIllegalRepository illegalRepository)
        {
            this.illegalRepository = illegalRepository;
        }

        public async Task<int> Handle(DelIllgalCommand request, CancellationToken cancellationToken)
        {
            var list = await illegalRepository.GetModelAsync(request.IllegalId);
            list.IsDel = true;
            var res=  await illegalRepository.UpdateAsync(list);
            return res;
        }
    }
}
